package com.hxzy.shop.order.controller;

import com.github.pagehelper.PageInfo;
import com.hxzy.shop.order.dto.req.OrderCountsReq;
import com.hxzy.shop.order.dto.req.OrderDetailReq;
import com.hxzy.shop.order.dto.req.OrderManageReq;
import com.hxzy.shop.order.dto.resp.OrderCountsResp;

import com.hxzy.shop.order.dto.resp.OrderDetailResp;
import com.hxzy.shop.order.dto.resp.OrderManageListResp;
import com.hxzy.shop.order.dto.resp.StoreResp;
import com.hxzy.shop.order.product.OrderProduct;
import com.hxzy.shop.order.service.OrderService;
import com.hxzy.shop.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;


@RestController
@Api(tags = "订单-订单")
@RequestMapping("/order")
public class OrderController {

    @Resource
    private OrderService orderService;

    @Resource
    private OrderProduct orderProduct;

    /**
     * 订单列表
     *
     * @param orderManageReq 订单请求体
     * @return 订单分页
     */
    @PostMapping("/getOrderManageList")
    @ApiOperation("订单管理分页")
    public Result<PageInfo<OrderManageListResp>> getOrderManageList(@RequestBody @Validated OrderManageReq orderManageReq) {
        System.out.println("是否有请求请求到....getOrderManageList---订单管理分页");
        return Result.success(orderService.getOrderManageList(orderManageReq));
    }

    /**
     * 获得所有门店
     *
     * @return 门店集合
     */
    @ApiOperation("订单所有门店")
    @PostMapping("/getStoreList")
    public Result<List<StoreResp>> getStoreList() {
        return Result.success(orderService.getStoreList());
    }

    /**
     * 获得订单列表总数
     *
     * @param orderCountsReq 请求体
     * @return 订单列表总数
     */
    @ApiOperation("获得订单列表总数")
    @PostMapping("/orderCountS")
    public Result<OrderCountsResp> orderCountS(@RequestBody OrderCountsReq orderCountsReq) {
        return Result.success(orderService.orderCountS(orderCountsReq));
    }

    /**
     * 订单详细
     *
     * @param orderDetailReq 订单详情请求体
     * @return 订单详情
     */
    @ApiOperation("订单详细")
    @PostMapping("/getOrderDetail")
    public Result<OrderDetailResp> getOrderDetail(@RequestBody @Validated OrderDetailReq orderDetailReq) {
        return Result.success(orderService.getOrderDetail(orderDetailReq));
    }

}
